﻿using EntityModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace PartyWorkSupervise.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class PeopleController : ControllerBase
    {
        private readonly PWSDBContext db;
        public PeopleController(PWSDBContext context)
        {
            db = context;
        }

        [HttpGet]
        public Result People()
        {
            Result result = new Result();
            var resulrData = db.EM_People.ToList<EM_People>();
            result.Data = resulrData;
            result.Supervisor = "1234567@qq.com";
            result.Code = 200;
            return result;
        }

        [HttpGet]
        public Result People(bool lableEmpty,bool lableChronic)
        {
            Result result = new Result();
            EM_People? people = db.EM_People.Where(s => s.lableEmpty == lableEmpty && s.lableChronic == lableChronic).SingleOrDefault();
            result.Data = people;
            result.Supervisor = "1234567@qq.com";
            result.Code = people == null ? 404 : 200;
            return result;
        }
    }
}
